package net.minecraft.src;

import java.io.*;
import java.util.List;

public class LF_EntitySeat extends Entity 
{
	boolean placedAlready = false;
	boolean firstUpdate = true;
	
	public LF_EntitySeat(World world)
	{
		super(world);
		setSize(1F, 1F);
		isAirBorne = false;
		onGround = true;
		yOffset = 0F;
		motionX = 0;
		motionY = 0;
		motionZ = 0;
	}

	public LF_EntitySeat(World world, double i, double j, double k)
	{
		this(world);
		setPosition(i, j, k);
		posX = i;
		posY = j;
		posZ = k;
		prevPosX = posX;
		prevPosY = posY;
		prevPosZ = posZ;
	}

	public LF_EntitySeat(World world, int i, int j, int k)
	{
		this(world, i+0.5F, j, k+0.5F);
	}

	public double blockX()
	{
		return posX - 0.5F;
	}

	public double blockY()
	{
		return posY;
	}

	public double blockZ()
	{
		return posZ - 0.5F;
	}

	@Override
	public AxisAlignedBB getBoundingBox()
	{
		return AxisAlignedBB.getBoundingBox(blockX(), blockY(), blockZ(), blockX() + 1, blockY() + 1, blockZ() + 1);
	}

	@Override
	public AxisAlignedBB getCollisionBox(Entity entity)
	{
		return AxisAlignedBB.getBoundingBox(blockX(), blockY(), blockZ(), blockX() + 1, blockY() + 1, blockZ() + 1);
	}

	@Override
	public void setLocationAndAngles(double d, double d1, double d2, float f, float f1)
	{
	}

	@Override
	public void setPositionAndRotation(double d, double d1, double d2, float f, float f1)
	{
	}

	@Override
	public void setPosition(double d, double d1, double d2)
	{
		if(!placedAlready) 
		{
			super.setPosition(d, d1, d2);
			placedAlready = true;
		}
	}

	@Override
	public void onEntityUpdate()
	{
		if(riddenByEntity != null)
		{
			((EntityLiving)riddenByEntity).rotationYaw = this.rotationYaw;
			((EntityLiving)riddenByEntity).prevRotationYaw = this.rotationYaw;
			System.out.println(this.rotationYaw);
		}
	}

	@Override
	public boolean interact(EntityPlayer player)
	{
		if(player.ridingEntity == null)
		{
			if(riddenByEntity == null)
			{
				player.mountEntity(this);

				riddenByEntity.setRotation(this.rotationYaw, riddenByEntity.rotationPitch);
			}
		}
		else
		{
			if(player.ridingEntity == this && riddenByEntity == player)
			{
				player.ridingEntity = null;
				riddenByEntity = null;
				player.setPosition(player.posX, player.posY + getMountedYOffset(), player.posZ);
				firstUpdate = true;
			}
		}

		return true;
	}

	@Override
	public boolean canBeCollidedWith()
	{
		return true;
	}

	@Override
	public double getMountedYOffset()
	{
		return 0.4375D;
	}

	@Override
	protected void entityInit()
	{
	}

	@Override
	public void writeEntityToNBT(NBTTagCompound nbttagcompound)
	{
	}

	@Override
	public void readEntityFromNBT(NBTTagCompound nbttagcompound)
	{
	}
}
